package com.yc.damai.web;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Enumeration;

public class AccessInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        final Enumeration<String> names = request.getHeaderNames();
        System.out.println("------------------request-------------------");
        while (names.hasMoreElements()) {
            final String name = names.nextElement();
            System.out.printf("%s : %s \r\n", name, request.getHeader(name));
        }
        System.out.println("------------------request-------------------");
        return true;
    }
}
